package com.lwbpro.web.controller.system;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.lwbpro.system.domain.vo.ExamManageReqVO;
import com.lwbpro.system.domain.vo.LineRespVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lwbpro.common.annotation.Log;
import com.lwbpro.common.core.controller.BaseController;
import com.lwbpro.common.core.domain.AjaxResult;
import com.lwbpro.common.enums.BusinessType;
import com.lwbpro.system.domain.AchievementManage;
import com.lwbpro.system.service.IAchievementManageService;
import com.lwbpro.common.utils.poi.ExcelUtil;
import com.lwbpro.common.core.page.TableDataInfo;

/**
 * 学生考试成绩管理Controller
 *
 * @author achievement
 * @date 2024-09-02
 */
@RestController
@RequestMapping("/system/achievement")
public class AchievementManageController extends BaseController
{
    @Resource
    private IAchievementManageService achievementManageService;

    /**
     * 查询学生考试成绩管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExamManageReqVO reqVO)
    {
        startPage();
        List<AchievementManage> list = achievementManageService.selectAchievementManageList(reqVO);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('system:achievement:list')")
    @GetMapping("/line")
    public AjaxResult line(ExamManageReqVO reqVO)
    {
        return success(achievementManageService.line(reqVO));
    }

    /**
     * 导出学生考试成绩管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:export')")
    @Log(title = "学生考试成绩管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamManageReqVO reqVO)
    {
        List<AchievementManage> list = achievementManageService.selectAchievementManageList(reqVO);
        ExcelUtil<AchievementManage> util = new ExcelUtil<AchievementManage>(AchievementManage.class);
        util.exportExcel(response, list, "学生考试成绩管理数据");
    }

    /**
     * 获取学生考试成绩管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(achievementManageService.selectAchievementManageById(id));
    }

    /**
     * 新增学生考试成绩管理
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:add')")
    @Log(title = "学生考试成绩管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AchievementManage achievementManage)
    {
        return toAjax(achievementManageService.insertAchievementManage(achievementManage));
    }

    /**
     * 修改学生考试成绩管理
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:edit')")
    @Log(title = "学生考试成绩管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AchievementManage achievementManage)
    {
        return toAjax(achievementManageService.updateAchievementManage(achievementManage));
    }

    /**
     * 删除学生考试成绩管理
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:remove')")
    @Log(title = "学生考试成绩管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(achievementManageService.deleteAchievementManageByIds(ids));
    }

    @PreAuthorize("@ss.hasPermi('system:achievement:query')")
    @GetMapping(value = "/achievementId/{id}")
    public AjaxResult radar(@PathVariable Long id) {
        return success(achievementManageService.radar(id));
    }
}
